package client_gui;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowListener;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;

import client_controllers.EmployeeLoginController;
import client_controllers.SalesManController;
import net.miginfocom.swing.MigLayout;

import javax.swing.JLabel;
import javax.swing.SpringLayout;

import com.jgoodies.forms.layout.FormLayout;
import com.jgoodies.forms.layout.ColumnSpec;
import com.jgoodies.forms.layout.RowSpec;

import javax.swing.JTextArea;

public class SalesManGUI extends JFrame {
	/**
	 * @class SalesManGUI generates frame for salesman employee
	 */
	

	private JLabel lblChooseCampaign;
	private JLabel lblsuccess;
	private JComboBox campaignBox;
	private JComboBox customerBox;
	private JComboBox futurePermissionCombo;
	private JButton btnLogout;
	private JTextField textFieldQuantity;
	private JPanel success;
	private JPanel fail;
	private JButton btnFinish;
	private JButton btnYes;
	private JButton btnGetCampaigns;
	private JButton btnNo;
	private JPanel panelFP;
	private JLabel lblproduct;
	private JButton btnAddPermition;
	private JButton btnGetProduct;
	private JLabel lblItem;
	private JTextArea freeText;
	private JLabel lblError_1;
	private JLabel lblPhone;
	private JTextField phonetext;

	public SalesManGUI(EmployeeLoginController elc) {
		
		this.setTitle("Salesman window");
		getContentPane().setLayout(null);
		getContentPane().setLayout(null);
		
		JPanel main = new JPanel();
		main.setBounds(10, 0, 464, 187);
		main.setLayout(null);
		getContentPane().add(main);
		
		
		lblError_1 = new JLabel("error");
		lblError_1.setForeground(Color.red);
		lblError_1.setVisible(false);
		this.setVisible(false);
		lblError_1.setBounds(154, 0, 89, 20);
		main.add(lblError_1);
		
		JLabel lblstart = new JLabel("select customer for addresing");
		lblstart.setBounds(101, 11, 194, 33);
		main.add(lblstart);
				
		customerBox = new JComboBox();
		customerBox.setBounds(133, 56, 144, 20);
		main.add(customerBox);
		
		JLabel lblcustomer = new JLabel("Choose Customer:");
		lblcustomer.setBounds(10, 58, 113, 17);
		main.add(lblcustomer);
		
		btnLogout = new JButton("logout");
		btnLogout.setBounds(353, 16, 89, 23);
		main.add(btnLogout);	
		
		lblsuccess = new JLabel("the sale success?");
		lblsuccess.setVisible(false);
		lblsuccess.setVisible(false);
		lblsuccess.setBounds(10, 141, 131, 14);
		main.add(lblsuccess);
		
		btnYes = new JButton("yes");
		btnYes.setVisible(false);
		btnYes.setVisible(false);
		btnYes.setBounds(131, 137, 89, 23);
		main.add(btnYes);
		
		
		btnNo = new JButton("no");
		btnNo.setVisible(false);
		btnNo.setVisible(false);
		btnNo.setBounds(264, 137, 89, 23);
		main.add(btnNo);
		
		lblChooseCampaign = new JLabel("Choose campaign:");
		lblChooseCampaign.setVisible(false);
		lblChooseCampaign.setBounds(10, 86, 113, 20);
		main.add(lblChooseCampaign);
		
		campaignBox = new JComboBox();
		campaignBox.setVisible(false);
		campaignBox.setBounds(133, 86, 144, 20);
		main.add(campaignBox);
		
		btnGetCampaigns = new JButton("Get campaigns");
		btnGetCampaigns.setVisible(false);
		btnGetCampaigns.setBounds(305, 54, 144, 23);
		main.add(btnGetCampaigns);
		
		lblItem = new JLabel("Product: ");
		lblItem.setVisible(false);
		lblItem.setBounds(10, 116, 63, 14);
		main.add(lblItem);
		
		lblproduct = new JLabel("aa");
		lblproduct.setVisible(false);
		lblproduct.setBounds(133, 117, 144, 14);
		main.add(lblproduct);
		
		btnGetProduct = new JButton("Get Product");
		btnGetProduct.setVisible(false);
		btnGetProduct.setBounds(305, 85, 144, 23);
		main.add(btnGetProduct);
		
		lblPhone = new JLabel("Duration of the call");
		lblPhone.setVisible(false);
		lblPhone.setBounds(133, 173, 113, 14);
		main.add(lblPhone);
		lblPhone.setVisible(false);
		
		
		phonetext = new JTextField();
		phonetext.setVisible(false);
		phonetext.setBounds(240, 167, 86, 20);
		main.add(phonetext);
		phonetext.setColumns(10);
		phonetext.setVisible(false);
		
		success = new JPanel();
		success.setBounds(10, 193, 248, 31);
		getContentPane().add(success);
		success.setLayout(null);
		
		textFieldQuantity = new JTextField();
		textFieldQuantity.setBounds(136, 0, 63, 20);
		success.add(textFieldQuantity);
		textFieldQuantity.setColumns(10);
		
		JLabel label = new JLabel("Requested Quantity: ");
		label.setBounds(0, 0, 126, 20);
		success.add(label);
		
		fail = new JPanel();
		fail.setVisible(false);
		fail.setBounds(266, 193, 208, 148);
		getContentPane().add(fail);
		fail.setLayout(null);
		
		JLabel lblCustomerComment = new JLabel("customer comment");
		lblCustomerComment.setBounds(49, 11, 149, 14);
		fail.add(lblCustomerComment);
		
		freeText = new JTextArea();
		freeText.setBounds(21, 36, 166, 88);
		fail.add(freeText);
		
		panelFP = new JPanel();
		panelFP.setBounds(2, 235, 256, 106);
		getContentPane().add(panelFP);
		panelFP.setLayout(null);
		
		JLabel lblFuturePermission = new JLabel("Future Permission:");
		lblFuturePermission.setBounds(10, 11, 107, 23);
		panelFP.add(lblFuturePermission);
		
		btnFinish = new JButton("Finish");
		btnFinish.setBounds(0, 60, 89, 23);
		panelFP.add(btnFinish);
		
		futurePermissionCombo = new JComboBox();
		futurePermissionCombo.setBounds(120, 12, 114, 20);
		panelFP.add(futurePermissionCombo);
		
		btnAddPermition = new JButton("Add Permition");
		btnAddPermition.setBounds(120, 60, 126, 23);
		panelFP.add(btnAddPermition);
		
		main.setVisible(true);
		success.setVisible(false);
		fail.setVisible(false);
		panelFP.setVisible(false);
		
		setSize(500,374);
		SalesManController smc=new SalesManController(this, elc);
		setLocationRelativeTo(null);
		setVisible(true);
	}

	public JLabel getLblError_1() {
		return lblError_1;
	}

	public void setLblError_1(JLabel lblError_1) {
		this.lblError_1 = lblError_1;
	}

	public JButton getBtnFinish() {
		return btnFinish;
	}

	public void setBtnFinish(JButton btnFinish) {
		this.btnFinish = btnFinish;
	}

	public JLabel getLblItem() {
		return lblItem;
	}

	public void setLblItem(JLabel lblItem) {
		this.lblItem = lblItem;
	}

	public JButton getBtnGetProduct() {
		return btnGetProduct;
	}

	public void setBtnGetProduct(JButton btnGetProduct) {
		this.btnGetProduct = btnGetProduct;
	}

	public JComboBox<String> getFuturePermissionCombo() {
		return futurePermissionCombo;
	}

	public void setFuturePermissionCombo(JComboBox futurePermissionCombo) {
		this.futurePermissionCombo = futurePermissionCombo;
	}

	public JLabel getLblChooseCampaign() {
		return lblChooseCampaign;
	}

	public void setLblChooseCampaign(JLabel lblChooseCampaign) {
		this.lblChooseCampaign = lblChooseCampaign;
	}

	public JLabel getLblsuccess() {
		return lblsuccess;
	}

	public void setLblsuccess(JLabel lblsuccess) {
		this.lblsuccess = lblsuccess;
	}

	public JButton getBtnYes() {
		return btnYes;
	}

	public void setBtnYes(JButton btnYes) {
		this.btnYes = btnYes;
	}

	public JButton getBtnGetCampaigns() {
		return btnGetCampaigns;
	}

	public void setBtnGetCampaigns(JButton btnGetCampaigns) {
		this.btnGetCampaigns = btnGetCampaigns;
	}

	public JButton getBtnNo() {
		return btnNo;
	}

	public void setBtnNo(JButton btnNo) {
		this.btnNo = btnNo;
	}

	public JComboBox getCustomerBox() {
		return customerBox;
	}

	public void setCustomerBox(JComboBox customerBox) {
		this.customerBox = customerBox;
	}


	public JButton getBtnAddPermition() {
		return btnAddPermition;
	}

	public void setBtnAddPermition(JButton btnAddPermition) {
		this.btnAddPermition = btnAddPermition;
	}


	public JComboBox getCampaignBox() {
		return campaignBox;
	}

	public void setCampaignBox(JComboBox customerBox) {
		this.campaignBox = customerBox;
	}

	public JButton getBtnLogout() {
		return btnLogout;
	}

	public void setBtnLogout(JButton btnLogout) {
		this.btnLogout = btnLogout;
	}

	public JTextField getTextFieldQuantity() {
		return textFieldQuantity;
	}

	public void setTextFieldQuantity(JTextField textFieldQuantity) {
		this.textFieldQuantity = textFieldQuantity;
	}

	public JPanel getSuccess() {
		return success;
	}

	public void setSuccess(JPanel success) {
		this.success = success;
	}

	public JPanel getFail() {
		return fail;
	}

	public void setFail(JPanel fail) {
		this.fail = fail;
	}

	public JButton getBtnUpdate() {
		return btnFinish;
	}

	public void setBtnUpdate(JButton btnUpdate) {
		this.btnFinish = btnUpdate;
	}


	public JPanel getPanelFP() {
		return panelFP;
	}

	public void setPanelFP(JPanel panelFP) {
		this.panelFP = panelFP;
	}

	public void setupdatelis(ActionListener lis){
		this.btnFinish.addActionListener(lis);
	}
	public void setlogoutlis(ActionListener lis){
		this.btnLogout.addActionListener(lis);
	}
	public void setexittlis(WindowListener lis){
		this.addWindowListener(lis);
	}
	public JLabel getLblproduct() {
		return lblproduct;
	}

	public void setLblproduct(JLabel lblproduct) {
		this.lblproduct = lblproduct;
	}
	public JTextArea getFreeText() {
		return freeText;
	}

	public void setFreeText(JTextArea freeText) {
		this.freeText = freeText;
	}

	public JLabel getLblPhone() {
		return lblPhone;
	}

	public void setLblPhone(JLabel lblPhone) {
		this.lblPhone = lblPhone;
	}

	public JTextField getPhonetext() {
		return phonetext;
	}

	public void setPhonetext(JTextField phonetext) {
		this.phonetext = phonetext;
	}
	
	
}
